package cn.glutnn.controller;


import cn.glutnn.entity.*;
import cn.glutnn.entity.dto.RecommendDTO;
import cn.glutnn.service.BankService;
import cn.glutnn.service.BankUserService;
import cn.glutnn.service.FinanceService;
import cn.glutnn.service.FinancingIntentionService;
import cn.glutnn.utils.ThreadLocalUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * (Finance)表控制层
 *
 * @author msh
 * @since 2024-10-25 09:33:54
 */
@Tag(name = "融资管理模块")
@RestController
@RequestMapping("/finance")
public class FinanceController {
    /**
     * 服务对象
     */
    @Autowired
    private FinanceService financeService;

    @Autowired
    private FinancingIntentionService financingIntentionService;

    @Autowired
    private BankUserService bankUserService;
    @Autowired
    private BankService bankService;

    //查询融资意向
    @Operation(summary = "查询融资意向")
    @GetMapping("/selectIntentionByName")
    public Result<List<FinancingIntention>> selectIntentionByName() {
        return financingIntentionService.selectIntentionByName();
    }

    @PostMapping("/insertIntentionByName")
    //添加融资意向 insertIntentionByName
    @Operation(summary = "添加融资意向")
    public Result<FinancingIntention> insertIntentionByName(@RequestBody FinancingIntention financingIntention) {

        return financingIntentionService.insertIntentionByName(financingIntention);
    }


    //修改融资意向
    @PutMapping("/updateIntentionByName")
    @Operation(summary = "修改融资意向")
    public Result<FinancingIntention> updateIntentionByName(@RequestBody FinancingIntention financingIntention) {

        return financingIntentionService.updateIntentionByName(financingIntention);
    }


    //删除融资意向
    @Operation(summary = "删除融资意向")
    @DeleteMapping("/deleteIntentionByName")
    public Result<FinancingIntention> deleteIntentionByName() {
        return financingIntentionService.deleteIntentionByName();
    }

    //查询推荐融资人
    @Operation(summary = "查询推荐融资人")
    @GetMapping("/selectRecommendByName")
    public Result<List<RecommendDTO>> selectRecommendByName() {

        return financeService.selectRecommendByName();
    }

    //添加单人贷款add
    @Operation(summary = "添加单人贷款")
    @PostMapping("/add")
    public Result<Finance> add(@RequestBody Finance finance) {
        return financeService.add(finance);
    }

    //查询银行情报
    @Operation(summary = "查询银行情报")
    @GetMapping("/selectBank")
    public Result<List<Bank>>  selectBank() {
        return bankService.selectAllBank();
    }

    //添加组合贷款addFinanceMulti
    @Operation(summary = "添加组合贷款")
    @PostMapping("/addFinanceMulti")
    public Result<Finance> addFinanceMulti(@RequestBody Finance finance) {
        return financeService.addFinanceMulti(finance);
    }

    //查询融资情况
    @Operation(summary = "查询融资情况")
    @GetMapping("/selectByName")
    public Result<List<Finance>> selectByName() {
        return financeService.selectByName();
    }

    //根据id修改融资情报
    @Operation(summary = "根据id修改融资情报")
    @PutMapping("/update")
    public Result<Finance> updateById(@RequestBody Finance finance) {
        return financeService.updateFinanceById(finance);
    }


    //根据id删除融资情报
    @Operation(summary = "根据id删除融资情报")
    @DeleteMapping("/delete/{id}")
    public Result<Finance> deleteById(@PathVariable("id") Integer id) {
        return financeService.deleteById(id);
    }

    //根据id查询融资情报
    @Operation(summary = "根据id查询融资情报")
    @GetMapping("/selectById/{id}")
    public Result<Finance> selectById(@PathVariable("id") Integer id) {
        return financeService.selectById(id);
    }


    //根据bankId查询银行信息
    @Operation(summary = "根据bankId查询银行信息")
    @GetMapping("/selectBankById/{bankId}")
    public Result<Map<String, Object>> selectBankById(@PathVariable("bankId") Integer bankId) {
        return bankUserService.selectBankById(bankId);
    }
}



